import sqlalchemy
from sqlalchemy.sql import and_, or_

engine = sqlalchemy.create_engine("mysql://root:root@localhost/test", echo=True)

meta_data = sqlalchemy.MetaData()

person = sqlalchemy.Table(
    "person",meta_data,
    sqlalchemy.Column("id", sqlalchemy.Integer, primary_key=True),
    sqlalchemy.Column("name", sqlalchemy.String(32), unique=True,nullable=False)
)

meta_data.create_all(engine)

# insert_person = person.insert()
# insert = insert_person.values(name="admin2")

# with engine.connect() as conn:
#     result = conn.execute(insert)
#     print(result.lastrowid)
#     conn.commit()

updata_sql = person.update().values(name="tom").where(person.c.id==2)
with engine.connect() as conn:
    result = conn.execute(updata_sql)
    print(result.rowcount)
    conn.commit()